<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"           
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      >
    <h:head>
        <f:metadata>
            <f:viewParam name="patientID" value="#{sessionBean.patientID}"/>
            <f:event type="preRenderView" listener="#{sessionBean.getPatientInfo}"/>
        </f:metadata>         
    </h:head>
    <h:body>
        <ui:composition template="template/masterlayout.xhtml">
            <ui:define name="pagetitle">
                Add new session
            </ui:define>
            <ui:define name="breadcrumb">
                <h:link value="Dashboard" outcome="index"/> &raquo; <h:link value="Patients management" outcome="patients"/> &raquo; 
                <h:link value="#{sessionBean.patientName}" outcome="patient.xhtml?patientID=#{sessionBean.patientID}"/> &raquo; Add new session
            </ui:define>
            <ui:define name="content">
                <h:form>
                    <fieldset>
                        <p>
                            <h:outputLabel for="sessionDate">Date(yyyy-MM-dd):</h:outputLabel>
                            <h:inputText id="sessionDate" value="#{sessionBean.sessionDate}" converterMessage="${msgs.Session_Date}">
                                <f:convertDateTime pattern="yyyy-MM-dd"/>
                            </h:inputText>
                            <h:message for="sessionDate" styleClass="error"/>
                        </p>
                        <p>
                            <h:outputLabel for="doctor">Doctor:</h:outputLabel>
                            <h:selectOneMenu id="doctor" value="#{sessionBean.doctor}">
                                <f:selectItem itemValue="Dr Ian Knight" itemLabel="Dr Ian Knight" />
                                <f:selectItem itemValue="Dr Faizan Ahmed" itemLabel="Dr Faizan Ahmed" />
                                <f:selectItem itemValue="Cathy Jandu" itemLabel="Cathy Jandu"/>
                                <f:selectItem itemValue="Dr Paul Lambden" itemLabel="Dr Paul Lambden"/>
                                <f:selectItem itemValue="Ceara Glackin" itemLabel="Ceara Glackin"/>
                            </h:selectOneMenu>                            
                        </p>    
                        <p>
                            <h:outputLabel for="require">Require:</h:outputLabel>                            
                            <h:inputTextarea id="require" value="#{sessionBean.require}"/>
                        </p>    
                        <p>
                            <h:outputLabel for="diagnostic">Diagnostic:</h:outputLabel>
                            <h:inputTextarea id="diagnostic" value="#{sessionBean.diagnostic}"/>
                        </p>
                        <p>
                            <h:outputLabel for="drugs">Drugs: </h:outputLabel>
                            <h:selectManyListbox id="drugs" value="#{sessionBean.selectedDrugs}">
                                <f:selectItems value="#{sessionBean.drugs}" var="drug"
                                               itemLabel="#{drug.drugName} - #{drug.drugPrice} $" itemValue="#{drug.drugID}" />
                            </h:selectManyListbox>    
                        </p>
                        <p>
                            <h:outputLabel for="services">Services: </h:outputLabel>
                            <h:selectManyListbox id="services" value="#{sessionBean.selectedServices}">
                                <f:selectItems value="#{sessionBean.services}" var="service"
                                               itemLabel="#{service.serviceName} - #{service.servicePrice} $" itemValue="#{service.serviceID}" />
                            </h:selectManyListbox>    
                        </p>                        
                        <p>
                            <h:commandButton styleClass="button-submit" value="Add Session" action="#{sessionBean.addSession()}"/>
                        </p>
                    </fieldset>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

